using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace QLTV.HeThongGiaoDien
{
    public partial class F_TimKiem : DevExpress.XtraEditors.XtraForm
    {
        public string _Ma, kq1, kq2, kq3, kq4, _TieuDe, _Bang, _DieuKien, _fill1, _fill2, _fill3, _fill4, _cap1, _cap2, _cap3;
        public F_TimKiem()
        {
            InitializeComponent();
        }

        private void B_Exit_Click(object sender, EventArgs e)
        {
            this.Close();
            _Ma = "";
                        
        }

        private void F_TimKiem_Load(object sender, EventArgs e)
        {
            TieuDe.Caption = _TieuDe;
            Colum1.Caption = _cap1;
            Colum2.Caption = _cap2;
            
            Colum1.FieldName = _fill1;
            Colum2.FieldName = _fill2;
            if (_fill3 != "")
            {
                Colum3.Visible = true;
                Colum3.Caption = _cap3;
                Colum3.FieldName = _fill3;
            }
            LoadDuLieu();
        }
        void LoadDuLieu()
        {
            DataTable ds = HeThongXuLy.TimKiem.Thongtin(_Bang,_Ma,_DieuKien);
            // hien thi danh sach len luoi
            gDanhSachTimKiem.DataSource = ds;     

        }

        private void ThongTinTimKiem_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            if (ThongTinTimKiem.DataRowCount > 0)
            {
                // Row dang Chon
                int row = ThongTinTimKiem.FocusedRowHandle;
                DataRow dr = ThongTinTimKiem.GetDataRow(row);
               kq1 = dr[_fill1].ToString();
               kq2 = dr[_fill2].ToString();
               if (_fill3!="")
               {
                   kq3 = dr[_fill3].ToString();
               }
            }        
        }

        private void ThongTinTimKiem_DoubleClick(object sender, EventArgs e)
        {
            this.Close();
        }

        
    }
}